package com.dulichdanang;

import java.util.ArrayList;
import java.util.List;
import android.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class HomeAdapter extends BaseAdapter {

	LayoutInflater inflater;
	List<HomeListItem> items;
	public HomeAdapter(Activity _context, List<HomeListItem> _list){
		super();
		this.items = _list;
		this.inflater = (LayoutInflater)_context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		HomeListItem item = items.get(position);
    	View vi=convertView;       
//        if(convertView==null)
//            vi = inflater.inflate(com.dulichdanang.R.layout.listitem_home, null);
//        ImageView imageThum = (ImageView)vi.findViewById(com.dulichdanang.R.id.imgThumbnail);
//       	TextView txtTitle = (TextView)vi.findViewById(com.dulichdanang.R.id.txtTitle);
//       	TextView txtSub = (TextView)vi.findViewById(com.dulichdanang.R.id.txtSubTitle);
//        imageThum.setImageResource(item.imageResource);
//        txtTitle.setText(item.title);
//        txtSub.setText(item.subTitle);
    	 if(convertView==null)
             vi = inflater.inflate(com.dulichdanang.R.layout.griditem_home, null);
         ImageView imageThum = (ImageView)vi.findViewById(com.dulichdanang.R.id.imgGvHome);
         TextView txtTitle = (TextView)vi.findViewById(com.dulichdanang.R.id.tvGvHome);
         imageThum.setImageResource(item.imageResource);
         txtTitle.setText(item.title);
         return vi;  
	}

}
